package com.mcy.springbatch.processer;

import com.mcy.springbatch.entity.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 接收参数，需加上@StepScope
 * @author : Create By mcy
 * @date : 2019/8/26 11:05:05
 */
@Slf4j
@JobScope
@Component
public class ParamItemProcessor implements ItemProcessor<SysUser,SysUser> {

    private String sysDate;
    private String sysTime;

    public ParamItemProcessor(@Value("#{jobParameters[sys_date]}")String sysDate, @Value("#{jobParameters[sys_time]}")String sysTime) {
        this.sysDate = sysDate;
        this.sysTime = sysTime;
    }

    @Override
    public SysUser process(SysUser item) throws Exception {
        log.info("参数处理的processor，线程ID：{},sysDate:{},sysTime:{}",Thread.currentThread().getId(),sysDate,sysTime);
        return item;
    }
}
